#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int write_file(const char* path, char* data)
{
    FILE* fp = fopen(path, "w");
    if (!fp)
    {
        perror(path);
        return 1;
    }

    fprintf(fp, data);

    fclose(fp);
    return 0;
}

int read_file(const char* path, float* data)
{
    FILE* fp = fopen(path, "r");
    if (!fp)
    {
        perror(path);
        return 1;
    }

    fscanf(fp, "%f", data);

    fclose(fp);
    return 0;
}